package cn.bluedot.controller;



import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


import cn.bluedot.bean.DataBaseBody;
import cn.bluedot.bean.PageBean;
import cn.bluedot.model.Pig;
import cn.bluedot.service.PigService;


@Controller
@RequestMapping("/pig")
public class PigController {
    @Resource
    private PigService pigService;
    
    @RequestMapping("/pigGrowthManage")
    @ResponseBody
    public JSONObject getPigs(@RequestParam Map<String,String> requestMap){
        String page = requestMap.get("page");
        String pigType = requestMap.get("pigType");
        String pigGrowth = requestMap.get("growth");
        
        Long LpigType = Long.parseLong(pigType);
        Long LpigGrowth = Long.parseLong(pigGrowth);
        
        //获取按照pb页面设置查询的对应的数据
        PageBean<Pig> pb = pigService.getPigs(page, LpigType, LpigGrowth);
        //response返回的json数据对象
        DataBaseBody dbb = DataBaseBody.getSuccessDataBody(pb);
        
        return JSONObject.parseObject(JSON.toJSONString(dbb));
    }
}
